<?php
/**
 * @author     ：lhw
 * @date       ：Created in 2019/8/4 16:03
 */

namespace app\api\model;

class Drug extends BaseModels
{
    protected $autoWriteTimestamp = 'datetime';

    public function img(){
        return $this->hasMany('DrugImg','drug_id','id')->order('num');
    }

    public function kinds(){
        return $this->belongsToMany('Kind','DrugKinds','kind_id','drug_id');
    }

    function father(){
        return $this->hasOne('Pharmacy','id','father_pharmacy');
    }

    function parents(){
        return $this->belongsToMany('Pharmacy','DrugPharmacy')->where('parent_id','<>',0);
    }

}